﻿<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/easyui/datagrid-detailview.js"></script>

<body class="easyui-layout">

<div data-options="region:'center',border:false" style="padding:2px;height: auto">
	<table id="equipment_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
		   data-options="rownumbers:true,
		   				   pagination:true,
		   				   singleSelect:true,
		   				   url:'/equip-list-json/1/20',
          				   method:'get',

           			   toolbar:'#tb',
						   showFooter: true">
        <#include "/common/thead.html">
	</table>
</div>

<!-- 操作栏 -->
<div id="tb" style="padding:5px;height:auto">
    设备分类:
    <input class="easyui-combobox" name="equipType"id="equipType"
           data-options="
				url : '/constants/equipment-types',
				method: 'get',
				valueField:'key',
				textField:'value',
				">
    资产归属单位:
    <input class="easyui-combobox" name="equipBelongTo"id="equipBelongTo"
           data-options="
				url : '/constants/equipment-belong',
				method: 'get',
				valueField:'key',
				textField:'value',
				">
    租赁状态:
    <input class="easyui-combobox" name="equipRentState"id="equipRentState"
           data-options="
				url : '/constants/equipment-rent-state',
				method: 'get',
				valueField:'key',
				textField:'value',
				">
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
    <#include "/common/button.html">
</div>

<!-- 详细 -->
<script type="text/javascript">
    $('#equipment_table').datagrid({
        view: detailview,
        detailFormatter: function(rowIndex, rowData){
            return '<table><tr>' +
                    '<td rowspan=5 style="border:0">' +
                    '<img src="/echarts/'+rowIndex+'.png" style="height:200px;">' +
                    '</td>' +
                    '<td style="border:0">' +
                    '<p><span style="font-weight:bold">设备规格</span>: ' + rowData.equipSpecifications + '</p>' +
                    '<p><span style="font-weight:bold">设备厂商</span>: ' + rowData.equipFactory + '</p>' +
                    '</td>' +
                    '</tr></table>';
        }
    });
</script>

<script>
    $("#searchByParameter").click(function(){
        var equipType = $("#equipType").val();
        var equipBelongTo = $("#equipBelongTo").val();
        var equipRentState = $("#equipRentState").val();
        var handler = '/equip-list-json/1/20?equipType='+equipType+'&equipBelongTo='+equipBelongTo+'&equipRentState='+equipRentState;
        $('#equipment_table').datagrid('options').url = handler;
        $('#equipment_table').datagrid('reload');
    });
    //新增
	$('#add').click(function () {
        var url = '/equipment-add/-1';
        var index = layer.open({
            title:'新增设备信息',
            type: 2,
            fixed: false, //不固定
            maxmin: false,
            content: url
        });
        layer.full(index);
    });
	//编辑
	$('#edit').click(function () {
        var row = $('#equipment_table').datagrid('getSelected');
        if(!row){
            layer.msg('请选择需要编辑的设备', {icon: 2});
        }else{
            var url = '/equipment-add/'+row.id;
            var index = layer.open({
                title:'新增设备信息',
                type: 2,
                fixed: false, //不固定
                maxmin: false,
                content: url
            });
            layer.full(index);
        }

    });
	//删除
	$('#delete').click(function () {
        var row = $('#equipment_table').datagrid('getSelected');
        if(!row){
            layer.msg('请选择需要删除的设备', {icon: 2});
        }else {
            layer.confirm('确定删除此设备？', {
                btn: ['删除','取消'] //按钮
            }, function(){
                $.ajax({
                    url : '/equipment-save/'+row.id,
                    data : {deleteFlag:'Y',tm : new Date().getTime()},
                    async : false,
                    success : function(){
                        $('#equipment_table').datagrid('reload');
                    }
                });
                layer.closeAll('dialog');
            }, function(){

            });
        }
    });

</script>

<script type="text/javascript">
	$(function(){
		var p = $('#equipment_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 25, 35], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
				var handler = '/equip-list-json/'+pageNumber+'/'+pageSize;
				$('#equipment_table').datagrid('options').url = handler;
				$('#equipment_table').datagrid('reload');
			}
		});
	})

</script>


